package classifier;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.TreeMap;
import java.util.Map.Entry;

import polarity.Polarity;

import files.TweetManager;
import files.Tweet;

public class ClassifierManager 
{
	static ClassifierApple classifierApple = new ClassifierApple();
	static ClassifierGoogle classifierGoogle = new ClassifierGoogle();
	static ClassifierMicrosoft classifierMicrosoft = new ClassifierMicrosoft();
	static ClassifierTwitter classifierTwitter = new ClassifierTwitter();
	static ClassifierGeneral classifierGeneral = new ClassifierGeneral();
	
	private static ArrayList<Classifier> classifierAl = new ArrayList<Classifier>();
	
	private static Hashtable<String,Classifier> classifierHt = new Hashtable<String,Classifier>();
	
	public static Hashtable<String, Classifier> getClassifierHt() { return classifierHt; }
	
	public static ArrayList<Classifier> getClassifierAl() { return classifierAl; }
	
	public static ClassifierApple getClassifierApple() { return classifierApple; }
	public static ClassifierGoogle getClassifierGoogle() { return classifierGoogle; }
	public static ClassifierMicrosoft getClassifierMicrosoft() { return classifierMicrosoft; }
	public static ClassifierTwitter getClassifierTwitter() { return classifierTwitter; }
	public static ClassifierGeneral getClassifierGeneral() { return classifierGeneral; }
	
	public static TreeMap<String, Integer> stopWord = new TreeMap<String, Integer>();
	
	private ClassifierManager() { }
	
	public static void init() 
	{
		/*
		ClassifierApple.init();
		ClassifierGoogle.init();
		ClassifierMicrosoft.init();
		ClassifierTwitter.init();
		ClassifierGeneral.init();
		*/
		
		classifierAl.clear();
		classifierAl.add(classifierApple);
		classifierAl.add(classifierGoogle);
		classifierAl.add(classifierMicrosoft);
		classifierAl.add(classifierTwitter);
		
		classifierHt.put("general", classifierGeneral);
		classifierHt.put("apple", classifierApple);
		classifierHt.put("google", classifierGoogle);
		classifierHt.put("microsoft", classifierMicrosoft);
		classifierHt.put("twitter", classifierTwitter);
	}
	
	/*
	public static void addTweetTest(Tweet tweetTest)
	{
		TweetManager.addTweetTest(tweetTest);
	}
	*/
	
	public static void setTweetTestClassifier(Tweet tweetTest)
	{
		tweetTest.setClassifierMark(classifierHt.get(tweetTest.getMark()));
		/*
		switch( tweetTest.getMark())
		{
			case "apple": tweetTest.setClassifierMark(ca); break;
			case "google": tweetTest.setClassifierMark(cg); break;
			case "microsoft": tweetTest.setClassifierMark(cm);  break;
			case "twitter": tweetTest.setClassifierMark(ct); break;
			default: break; 
		}
		*/
	}
	
	public static void addTweetTrain(Tweet tweetTrain)
	{
		TweetManager.addTweetTrain(tweetTrain);
		classifierGeneral.addTweetTrain(tweetTrain);
		classifierHt.get(tweetTrain.getMark()).addTweetTrain(tweetTrain);
		tweetTrain.setClassifierMark(classifierHt.get(tweetTrain.getMark()));
		/*
		switch( tweetTrain.getMark())
		{
			case "apple": ca.addTweetTrain(tweetTrain); tweetTrain.setClassifierMark(ca); break;
			case "google": cg.addTweetTrain(tweetTrain); tweetTrain.setClassifierMark(cg); break;
			case "microsoft": cm.addTweetTrain(tweetTrain); tweetTrain.setClassifierMark(cm);  break;
			case "twitter": ct.addTweetTrain(tweetTrain); tweetTrain.setClassifierMark(ct); break;
			default: break; 
		}
		*/
        }
	
	public static TreeMap<String, Integer> getStopWord() { return stopWord; }
	
	public static void setStopWord(TreeMap<String, Integer> stopWord) { ClassifierManager.stopWord = stopWord;}
	
	
	
//	public static void printStopWord() 
//	{ 
//		for(Entry<String, Integer> set : stopWord.entrySet() )
//		{
//			System.out.println(set.getKey());
//		}
//	}

}
